package com.xxl.job.admin.core.model;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * Created by xuxueli on 16/9/30.
 */
@Entity
@Table(name = "IISP_BATCH_JOB_REG")
@NamedQueries({
	@NamedQuery(name = JobRegistry.DEL_DEAD, query = "delete from JobRegistry jr where jr.updateTime < :updateTime"),
	@NamedQuery(name = JobRegistry.QUERY_RECENT, query = "select jr from JobRegistry jr where jr.updateTime > :updateTime"),
	@NamedQuery(name = JobRegistry.FIND_BY_SAMPLE, query = "select jr from JobRegistry jr where jr.registryKey = :registryKey and jr.registryValue = :registryValue and jr.registryGroup = :registryGroup"),
	@NamedQuery(name = JobRegistry.UPDATE_KEY_VALUE, query = "update JobRegistry jr set jr.registryKey = :registryKey, jr.registryValue = :registryValue, jr.updateTime = :updateTime where jr.registryGroup = :registryGroup")
})
public class JobRegistry {
	public final static String DEL_DEAD = "JobRegistry.DelByDead";
	public final static String QUERY_RECENT = "JobRegistry.Recent";
	public final static String UPDATE_KEY_VALUE = "JobRegistry.UpdateKeyValue";
	public final static String FIND_BY_SAMPLE = "JobRegistry.BySample";
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE)
    private Long id;
    private String registryGroup;
    private String registryKey;
    private String registryValue;
	@Temporal(TemporalType.TIMESTAMP)
    private Date updateTime;

	/**
	 * 
	 */
	public JobRegistry() {
		super();
	}

	/**
	 * @param registryGroup
	 * @param registryKey
	 * @param registryValue
	 */
	public JobRegistry(String registryGroup, String registryKey, String registryValue) {
		super();
		this.registryGroup = registryGroup;
		this.registryKey = registryKey;
		this.registryValue = registryValue;
	}

	public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getRegistryGroup() {
        return registryGroup;
    }

    public void setRegistryGroup(String registryGroup) {
        this.registryGroup = registryGroup;
    }

    public String getRegistryKey() {
        return registryKey;
    }

    public void setRegistryKey(String registryKey) {
        this.registryKey = registryKey;
    }

    public String getRegistryValue() {
        return registryValue;
    }

    public void setRegistryValue(String registryValue) {
        this.registryValue = registryValue;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}
